<?php
class Menu_model extends CI_Model
{
	public function getMenuByLanguageAndType($lang = 'vi',$type)
	{
		$data  = array();
		$this->db->select ( 'm.id, ml.menu_name,m.link' );
		$this->db->from ( 'menus m' );
		$this->db->where ( 'm.public', '1' );
		$this->db->where ( 'm.menu_id_ref', NULL );
		$this->db->where ('m.type',$type);
		/*$this->db->order_by ( 'p.order' );*/
	/*	$this->db->join('photo ph','ph.product_id = p.id');*/
		$this->db->join ( 'menu_languages ml', 'm.id = ml.menu_id' );
		$this->db->join ( 'languages l', 'l.id = ml.language_id AND l.code =\'' . $lang . '\'' );
		
		$q = $this->db->get ();
		/*$q = $this->db->get('products');*/
		
		if ($q->num_rows ()) {
			$data = $q->result_array ();
		}
		$q->free_result ();
		return $data;
	}
}